package com.lungle.warmdiary.app.view.me.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.lungle.warmdiary.R;
import com.lungle.warmdiary.app.model.response.TesterStat;
import com.lungle.warmdiary.app.view.me.view.BaseViewHolder;

import java.util.List;

public class PassAdapter extends BaseAdapter {

    private List<TesterStat> list;
    private Context mContext;


    public PassAdapter(Context context, List<TesterStat> list) {
        this.list = list;
        this.mContext = context;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(
                    R.layout.item_industry_picture, parent, false);
        }
        final TesterStat testerStat = list.get(position);
        ImageView picture = BaseViewHolder.get(convertView, R.id.iv_industry_img);
        if (!TextUtils.isEmpty(testerStat.getIcon())) {
            ImageLoader.getInstance().displayImage(testerStat.getIcon(), picture);
        }
        return convertView;
    }
}